package com.zmn.plat.services.impl.funswitch;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zmn.common.dto.StatusDTO;
import com.zmn.common.utils.string.StringUtil;
import com.zmn.plat.model.entity.funswitch.PublicBaseCodeMap;
import com.zmn.plat.model.entity.funswitch.PublicBaseCodeMapQuery;
import com.zmn.plat.persistence.interfaces.funswitch.BaseCodeMapMapper;
import com.zmn.plat.services.interfaces.funswitch.PublicBaseCodeMapService;

/**
 * 公共配置管理
 * 
 * @author hedaiping
 * @create 2019/03/25/14:17
 */

@Service
public class PublicBaseCodeMapServiceImpl implements PublicBaseCodeMapService {

    @Autowired
    private BaseCodeMapMapper baseCodeMapMapper;

    @Override
    public PublicBaseCodeMap findByKey(Integer mapId) {
        return baseCodeMapMapper.findByKey(mapId);
    }

    @Override
    public Integer findKeyForMax() {
        return baseCodeMapMapper.findKeyForMax();
    }

    @Override
    public List<PublicBaseCodeMap> listPageByQuery(PublicBaseCodeMapQuery query) {
        int count = countByQuery(query);
        query.setTotalCount(count);
        return baseCodeMapMapper.listPageByQuery(query);
    }

    @Override
    public List<PublicBaseCodeMap> listByQuery(PublicBaseCodeMapQuery query) {
        return baseCodeMapMapper.listByQuery(query);
    }

    @Override
    public List<PublicBaseCodeMap> listAll() {
        return baseCodeMapMapper.listAll();
    }

    @Override
    public Integer countByQuery(PublicBaseCodeMapQuery query) {
        return baseCodeMapMapper.countByQuery(query);
    }

    @Override
    public Integer updateByKey(PublicBaseCodeMap baseCodeMap) {
        return baseCodeMapMapper.updateByKey(baseCodeMap);
    }

    @Override
    public Integer updateStatus(PublicBaseCodeMap baseCodeMap) {
        return baseCodeMapMapper.updateStatus(baseCodeMap);
    }

    @Override
    public Integer updateStatusBatch(StatusDTO dto) {
        return baseCodeMapMapper.updateStatusBatch(dto);
    }

    @Override
    public Integer insert(PublicBaseCodeMap baseCodeMap) {
        return baseCodeMapMapper.insert(baseCodeMap);
    }

    @Override
    public Integer deleteByKey(Integer mapId) {
        return baseCodeMapMapper.deleteByKey(mapId);
    }

    @Override
    public Integer getStatusByName(String name) {
        if (StringUtil.isBlank(name)) {
            return 0;
        }
        return baseCodeMapMapper.getStatusByName(name);
    }
}
